/**
 * 
 */
package org.conan.groupapp.system.web.filter;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.conan.groupapp.framework.action.BaseAction;
import org.conan.groupapp.system.entity.User;
import org.springframework.security.core.Authentication;
import org.springframework.security.web.authentication.SimpleUrlAuthenticationSuccessHandler;

/**
 * @author Administrator
 * 认证成功后，并将数据保存到session
 */
public class CustomSimpleUrlAuthenticationSuccessHandler extends SimpleUrlAuthenticationSuccessHandler {


	@Override
	public void onAuthenticationSuccess(HttpServletRequest request,
			HttpServletResponse response, Authentication authentication)
			throws IOException, ServletException {
		System.out.println("onAuthenticationSuccess start");
		super.onAuthenticationSuccess(request, response, authentication);
		//保存数据到session
		request.getSession().setAttribute(BaseAction.USER_SESSION_NAME, (User)authentication.getPrincipal());
		System.out.println("onAuthenticationSuccess end");
	}	
	
	

}
